package com.cari.oa.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cari.oa.dao.BaseDao;
import com.cari.oa.dao.SoftProjectDao;
import com.cari.oa.domain.SoftProjectEntity;

@Service
@Transactional(rollbackFor = Exception.class)
public class SoftProjectService extends BaseService<SoftProjectEntity> {
	
	@Resource
	private SoftProjectDao softProjectDao;

	@Override
	public BaseDao<SoftProjectEntity> getDao() {
		return softProjectDao;
	}

	/**
    * Title: getPage
    * Description:分页查询软件项目实体对象
    * @author    hjx 
    * @date       2013-1-16 
    * @param name 项目名称
    * @param status 项目状态
    * @param startTime 开始时间
    * @param page 第几页
    * @param size 每页显示几条
    * @return
    */
	@Transactional(readOnly = true)
    public List<SoftProjectEntity>  getPage(String name, String status, Date startTime,Date endTime, int page, int size) {
    	return softProjectDao.getPage(name, status, startTime,endTime,page, size);
    }
     
	/**
    * Title: getCount
    * Description: 查询符合条件的记录数
    * @author    hjx 
    * @date       2013-1-16 
    * @param name 项目名称
    * @param status 项目状态
    * @param startTime 开始时间
    * @return
    */
	@Transactional(readOnly = true)
    public long getCount(String name, String status, Date startTime,Date endTime) {
    	return softProjectDao.getCount(name, status,startTime,endTime);
    }	
	
    /**
     * 判断项目名称是否已经存在
     * @param name 项目名称
     * @return 是否存在
     */
	@Transactional(readOnly = true)
    public boolean existByEnname(String name) {
        return softProjectDao.existByName(name);
    }

	/**
	* Title: addProjectUserRel
	* Description: 添加参与项目的用户关系
	* @author    hjx 
	* @date       2013-1-17 
	* @param projectId
	* @param selectedUserEnname
	*/
	public void addProjectUserRel(String projectId,List<String> selectedUserEnname,String type) { 
		softProjectDao.addProjectUserRel(projectId,selectedUserEnname,type);
	}

	/**
	* Title: getUserByProjectId
	* Description: 获取项目底下的人员信息
	* @author    hjx 
	* @date       2013-1-30 
	* @param projectId
	* @return
	*/
	public List<Map<String,String>> getUserByProjectId(String projectId,String deptNo) {
		return softProjectDao.getUserByProjectId(projectId,deptNo);
	}

	public List<SoftProjectEntity> getByStatus() {
	
		return softProjectDao.getByStatus();
	}

	/**
	* Title: getProjectListByEnname
	* Description:获取用户参与的所以项目
	* @author    hjx 
	* @date       2013-4-24 
	* @param enname
	 */
	public  List<SoftProjectEntity> getProjectListByEnname(String enname) {
		
		return softProjectDao.getProjectListByEnname(enname);
	}

	public boolean getByName(String projectName) {
		return softProjectDao.getByName(projectName);
	}	

}
